package com.example.administrator.xiaobo.utils;

import java.util.LinkedList;
import java.util.Random;

/**
 * Created by Administrator on 2017/2/9.
 */

public class ListRandomHelper {
    public static boolean isEmpty(LinkedList sourceList) {
        return (sourceList == null || sourceList.size() == 0); }

    public static LinkedList randomList(LinkedList sourceList){
        if (isEmpty(sourceList)) { return sourceList; }
        LinkedList randomList = new LinkedList();
        do{ int randomIndex = Math.abs( new Random( ).nextInt( sourceList.size() ) );
            randomList.add( sourceList.remove( randomIndex ) );
        }while( sourceList.size( ) > 0 );
        return randomList; }
}
